/**
 * 访问邀请模型
 */
class Invite extends CommonModels {
    tableFields() {
        return {
            "UID": {
                "label": "用户ID",
                "type": "int(11)"
            },
            "building_id": {
                "label": "楼宇ID",
                "type": "int(11)"
            },
            "company_id": {
                "label": "公司ID",
                "type": "int(11)"
            },
            "inviter": {
                "label": "邀请人",
                "type": "int(11)"
            },
            "start_time": {
                "label": "生效时间",
                "type": "datetime"
            },
            "end_time": {
                "label": "失效时间",
                "type": "datetime"
            },
            "status": {
                "label": "状态 0待审核 1通过 2拒绝",
                "type": "int(1)",
                "defaultValue":0
            },
            "note":{
                "label": "备注",
                "type": "varchar(500)"
            }
        }
    }

    rules() {
        return {

        }
    }

    tableName() {
        return '{{%visitor_invite}}';
    }

    getCompany(){
        return this.belongsTo({name:M('Company').tableName(),as:'company_info'},'company_id', 'id',['id','name']);
    }

    getUser(){
        return this.belongsTo({name:M('User').tableName(),as:'user_info'},'UID', 'id',['id','real_name','mobile']);
    }

}

export default Invite;